package servlets;

import javax.servlet.*;
import java.io.IOException;
import java.util.Enumeration;

public class SomeServlet implements Servlet {

    private ServletConfig config;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        this.config = servletConfig;
    }

    @Override
    public ServletConfig getServletConfig() {
        return config;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        ServletContext sc = config.getServletContext();

        //获取所有初始化参数名称
        Enumeration<String> names = sc.getInitParameterNames();
        while (names.hasMoreElements()) {

            String name = names.nextElement();

            String value = sc.getInitParameter(name);

            System.out.println(name + " = " + value);
        }


//        设置域属性
        sc.setAttribute("email","xxx@126.com");
        sc.setAttribute("mobile","123456");




    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
